    <div class="nav-sub w1180">
    	<ul class="zoom">
    		<li><a class="on" href="/crm/voucher/index">优惠券管理</a></li>
    	</ul>
    </div>
	<div class="main-ct w1180">

		<div class="top-bar">
			<div class="custom-search">
				<label>代金券名称<input id="name" type="text" class="tp-txt"></label>
				<label>商家名称<input id="org_name" type="text" class="tp-txt"></label>
				<a href="javascript:search();" class="btn-cs btn-search ml5">查 询</a>
				<a href="/crm/voucher/excel-voucher" class="btn-cs btn-green ml5">输出报表</a>
			</div>
			<a class="btn-cs btn-fillet btn-green" href="/crm/voucher/add-voucher">生成代金券</a>
		</div>
		<div class="row" id="list_table">

		</div>
	</div>
<script type="text/javascript">
var name = $("#name").val();
var org_name = $("#org_name").val();
var page = 1;

$(document).ready(function(){
	ajaxListTable();
});

function search(){
	page = 1;
	name = $("#name").val();
	org_name = $("#org_name").val();

	ajaxListTable();
}

function ajaxListTable(){
	$.ajax({
        type: "post",
        url : "<?php echo $this->url('crm/voucher',
            array('action'=>'ajax-voucher-table'));?>",
        dataType:'html',
        data:  { 
            "name": name, 
            "org_name": org_name, 
			"page":page },
        cache: false,
        timeout:10000, 
        error: function(){
          	 alert('请求超时，请重新操作');
           	 isPost = false;
             return false; 
         }, 
        success: function(html){
        	$("#list_table").html(html);
        }
    });
}
function deleteVt(vt_id){

    if(confirm("确定要删除吗？"))
    {
        $.ajax({
            type: "post",
            url: "<?php echo $this->url('crm/voucher',
            array('action'=>'delete'));?>",
            dataType:'json',
            data: { 
    				"vt_id":vt_id
    		},
            cache: false,
            timeout:10000, 
            error: function(err){
              	 alert('请求超时，请重新操作');
                 return false; 
             }, 
            success: function(result){
                if(result.result != 'true'){
                    alert(result.reason);
                }
                ajaxListTable();
            }
        });
    }
}
</script>